function  [disp_loc, matrix, thetaBuffer] = moveNodes(noOfNodes,networkSize,R,disp_loc, velocity, thetaBuffer) 
        netXloc = disp_loc(:,2);
        netYloc = disp_loc(:,3);        
        time = 2;       
        % This loop to move the nodes during the simulation.
        for i = 1:noOfNodes;
            X1 = netXloc(i);
            Y1 = netYloc(i);  
            theta = thetaBuffer (i);       
            vX = velocity * (cos(theta)); 
            vY = velocity * (sin(theta));
            T = theta;
            TC = cos(theta);
            TS = sin(theta);
            X2 = X1 + (vX * time);
            Y2 = Y1 + (vY * time) ;
            if X2 > networkSize 
                temp = X2 - networkSize;
                X2 = networkSize - temp;
                netXloc(i)= X2;
            elseif X2 < 0
                netXloc(i)= X2 * (-1) ;
            else
                netXloc(i)= X2;
            end 
            if Y2 > networkSize
                temp = Y2 - networkSize;
                Y2 = networkSize - temp;
                netYloc(i)= Y2;
            elseif Y2 < 0
                netYloc(i)= Y2 * (-1) ;
            else                
                netYloc(i)= Y2;
            end
        end
        disp_loc(:,2) = netXloc;
        disp_loc(:,3) = netYloc ;
    r = 0;
    g = 1;
    b = 0;
    
    [matrix] = drawNodes(noOfNodes,netXloc, netYloc, R, r, g, b);
end